import RequestUtils from '@/utils/RequestUtils'

const groupName = 'system'
const apiName = 'dict'

export default {
  add(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  remove(id) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/${id}`,
      method: 'DELETE'
    })
  },
  edit(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  get(id) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/${id}`,
      method: 'GET'
    })
  },
  list(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/search`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  page(params = {}, page) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/search/${page.current}/${page.pageSize}`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  // 清理参数缓存
  clearCache() {
    return RequestUtils({
      url: '/sys/dict/clearCache',
      method: 'DELETE'
    })
  },
  // 导出字典类型
  exportType(query) {
    return RequestUtils({
      url: '/sys/dict/export',
      method: 'GET',
      params: query
    })
  }
}
